﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="VendorPriceList.aspx.cs" Inherits="TireService.Web.View.SalesView.VendorPriceList" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="img1" alt="" src="~/Images/Medium/wheel.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblVendorPriceList" runat="server" Text="Leverandør dækpriser"></asp:Label></h3>
            </td>
        </tr>
    </table>
    <hr />

    <!-- Javascript of action dropdown list -->
    <script language="javascript" type="text/javascript">

        // Function that handles actions selected in dropdown list
        function ActionClicked() {

            // Get selected action from dropdownlist
            var id = ddlAction.GetValue();

            if (id != null && id != 0) {
                if (id == 1) {
                    // Import vendor price list
                    callBackImportVendorPriceList.PerformCallback();

                    LoadingPanel.Show();
                }

            }
            else {
                alert('Ingen handling valgt');
            }
        }

        function OnCallbackImportVendorPriceListComplete(s, e) {

            LoadingPanel.Hide();

            gvTirePriceListUpdate.PerformCallback();

            if (e.result != '') {
                alert(e.result);
            }
        }

        function CallbackError() {
            alert('Fejl opstod - prøv venligst igen');
        }

    </script>

    <dx:ASPxLoadingPanel ID="LoadingPanel" Text="Vent venligst..." ClientInstanceName="LoadingPanel" runat="server" Modal="True">
    </dx:ASPxLoadingPanel>

    <dx:ASPxCallback ID="callBackImportVendorPriceList" ClientInstanceName="callBackImportVendorPriceList" runat="server" OnCallback="callBackImportVendorPriceList_Callback">
        <ClientSideEvents CallbackError="CallbackError" CallbackComplete="OnCallbackImportVendorPriceListComplete" />
    </dx:ASPxCallback>

    <table border="0" cellspacing="0" cellpadding="5" width="100%">
        <tr>
            <td style="width:150px">
                <dx:ASPxComboBox ID="ddlAction" ClientInstanceName="ddlAction" runat="server" Width="150px">
                    <Items>
                        <dx:ListEditItem Selected="true" Value="0" Text="-- Handling --" />
                        <dx:ListEditItem Value="1" Text="Importer nye priser" />
                    </Items>
                </dx:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dx:ASPxButton ID="btnSubmitAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False" Width="75px">
                    <ClientSideEvents Click="function(s, e) { ActionClicked(); }" />
                </dx:ASPxButton>
            </td>
            <td style="width:150px">
                <dx:ASPxComboBox ID="ddlExport" ClientInstanceName="ddlExport" runat="server" Width="150px">
                    <Items>
                        <dx:ListEditItem Selected="True" Value="0" Text="Export pdf" />
                        <dx:ListEditItem Value="1" Text="Export xls" />
                        <dx:ListEditItem Value="2" Text="Export csv" />
                        <dx:ListEditItem Value="3" Text="Export rtf" />
                    </Items>
                </dx:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dx:ASPxButton ID="btnExport" runat="server" Text="Exporter" OnClick="btnExport_Click" Width="75px" >
                </dx:ASPxButton>
            </td>
            <td align="right">
                <asp:Label ID="lblPageSize" runat="server" Text="Antal linjer pr side"></asp:Label>
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true">
                    <asp:ListItem Value="10">10</asp:ListItem>
                    <asp:ListItem Value="25">25</asp:ListItem>
                    <asp:ListItem Value="50">50</asp:ListItem>
                    <asp:ListItem Value="100">100</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>          
    <hr />
    <dx:ASPxGridView ID="gvTirePriceListUpdate" runat="server" ClientInstanceName="gvTirePriceListUpdate" 
        KeyFieldName="TirePriceListUpdateId" Width="100%" AutoGenerateColumns="False" EnableCallBacks="True" OnCustomCallback="gvTirePriceListUpdate_CustomCallback">
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <Settings ShowHeaderFilterButton="true" ShowGroupPanel="true" ShowFilterRow="True" />
        <SettingsPager AlwaysShowPager="True" PageSize="20" Position="TopAndBottom">
            <Summary 
                AllPagesText="Sider: {0} - {1} ({2} opdaterings datoer)" 
                Text="Side {0} af {1} ({2} opdaterings datoer)" />
        </SettingsPager>
        <SettingsText ConfirmDelete="" GroupPanel="Træk kolonne hertil for at gruppere efter den" HeaderFilterShowAll="Vis alle" />
        <SettingsBehavior ConfirmDelete="false" AllowGroup="false" AllowDragDrop="false" AllowFocusedRow="true" />
        <ClientSideEvents FocusedRowChanged="function(s, e) {
            if (typeof(gvTirePriceList) != 'undefined')
                gvTirePriceList.PerformCallback(s.GetFocusedRowIndex());
        }" 
        />
        <Columns>
            <dx:GridViewDataColumn FieldName="TirePriceListUpdateId" VisibleIndex="1" Caption="Id">
            </dx:GridViewDataColumn>
            <dx:GridViewDataColumn FieldName="UpdateDate" VisibleIndex="2" Caption="Dato for priser">
            </dx:GridViewDataColumn>
        </Columns>            
    </dx:ASPxGridView>
    <hr />
    <dx:ASPxGridView ID="gvTirePriceList" runat="server" ClientInstanceName="gvTirePriceList" Width="100%" 
        KeyFieldName="TirePriceListId" AutoGenerateColumns="False" EnableCallBacks="True" 
        oncustomunboundcolumndata="gvTirePriceList_CustomUnboundColumnData" OnCustomCallback="gvTirePriceList_CustomCallback">
        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
        <Settings ShowHeaderFilterButton="true" ShowGroupPanel="true" ShowFilterRow="True" />
        <SettingsPager AlwaysShowPager="True" PageSize="20" Position="TopAndBottom">
            <Summary 
                AllPagesText="Sider: {0} - {1} ({2} dæk)" 
                Text="Side {0} af {1} ({2} dæk)" />
        </SettingsPager>
        <SettingsText ConfirmDelete="Vil du slette denne lagerplads?" />
        <SettingsBehavior ConfirmDelete="false" AllowGroup="true" AllowFocusedRow="true" AllowDragDrop="true" AllowSelectByRowClick="true" />
        <ClientSideEvents Init="function(s, e) {
	        s.PerformCallback(gvTirePriceListUpdate.GetFocusedRowIndex());
        }" />

        <Columns>
            <dx:GridViewDataColumn FieldName="TirePriceListId" Visible="false" VisibleIndex="1" Caption="TirePriceListId">
            </dx:GridViewDataColumn>
            <dx:GridViewDataTextColumn FieldName="VendorItemNumber" VisibleIndex="2" Caption="Varenr">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2" Caption="Beskrivelse">
            </dx:GridViewDataTextColumn> 
            <dx:GridViewDataTextColumn FieldName="Model" VisibleIndex="2" Caption="Model">
            </dx:GridViewDataTextColumn> 
            <dx:GridViewDataTextColumn FieldName="CostPrice" VisibleIndex="2" Caption="Pris">
            </dx:GridViewDataTextColumn> 
            <dx:GridViewDataTextColumn FieldName="StockQuantity" VisibleIndex="2" Caption="Lager">
            </dx:GridViewDataTextColumn> 
            <dx:GridViewDataTextColumn FieldName="FlexPrice" VisibleIndex="2" Caption="Flexpris">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="FlexStockQuantity" VisibleIndex="2" Caption="Flexlager">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="TireTypeId" VisibleIndex="2" Caption="Type">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataColumn FieldName="TireDimensions" UnboundType="String" VisibleIndex="2" Caption="Dimensioner">
            </dx:GridViewDataColumn>    
            <dx:GridViewDataTextColumn FieldName="Width" VisibleIndex="2" Caption="Bredde">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Height" VisibleIndex="2" Caption="Profil">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Size" VisibleIndex="2" Caption="Diameter">
            </dx:GridViewDataTextColumn>           
            <dx:GridViewDataTextColumn FieldName="TireSpeedIndexId" VisibleIndex="2" Caption="Hast.indx">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="TireLoadIndexId" VisibleIndex="2" Caption="Loadindex">
            </dx:GridViewDataTextColumn>
        </Columns>                                            
    </dx:ASPxGridView>

                                
    <dx:ASPxGridViewExporter ID="gvExport" runat="server" GridViewID="gvTirePriceList">
    </dx:ASPxGridViewExporter>

</asp:Content>
